package com.example.spring_ioc.Component;

import com.example.spring_ioc.model.UserInfo;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;

@Component
public class UserComponent {
//    @Qualifier("userInfo2")
//    @Autowired// 属性注入

    @Resource(name="userInfo2")
    private UserInfo ui;// 这个字段是通过UserInfoComponent中的"new ..."和@Bean获取的
    public void say() {
        System.out.println("UserComponent.say...");
        System.out.println(ui);
    }
}
